\chapter{OpenCV and Openframeworks} \label{appendix2}
OpenCV code that takes the newest image from a web camera, that is connected to the computer, and puts the information in a matrix.

Shown below is a small OpenCV program that displays the video feed from a web camera on the screen.

\begin{tabbing} \hspace*{2cm}\= \hspace*{2cm}\= \hspace*{2cm}\= \kill
\> int main(int argc,char *argv[])\\
\> \{ \\
\> \> int c; \\
\> \> IplImage* color\_img; \\
\> \> CvCapture* cv\_cap = cvCaptureFromCAM(0); \\
\> \> cvNamedWindow("Video",0); // create window \\
\> \> for(;;) \{ \\
\> \> color\_img = cvQueryFrame(cv\_cap); // get frame \\
\> \> if(color\_img != 0) \\
\> \> cvShowImage("Video", color\_img); // show frame \\
\> \> c = cvWaitKey(10); // wait 10 ms or for key stroke \\
\> \> if(c == 27) \\
\> \> break; // if ESC, break and quit \\
\> \> \} \\
\> \> /* clean up */ \\
\> \> cvReleaseCapture( \& cv\_cap ); \\
\> \> cvDestroyWindow("Video"); \\
\> \} \\
\end{tabbing}

Openframeworks code that takes the newest image from a webcam, and outputs it on the screen:
Shown below is a small Openframeworks program that displays the video feed from a web camera on the screen.

\begin{tabbing} \hspace*{2cm}\= \hspace*{2cm}\= \hspace*{2cm}\= \kill
\> void testApp::setup()\{ \\
\> \> camWidth = 320; // try to grab at this size. \\
\> \> camHeight = 240; \\
\> \> vidGrabber.setVerbose(true); \\
\> \> vidGrabber.initGrabber(camWidth,camHeight); \\
\> \} \\
\> void testApp::update()\{ \\
\> \> vidGrabber.grabFrame(); \\
\> \} \\
\> void testApp::draw()\{ \\
\> \> vidGrabber.draw(0,0); \\
\> \}
\end{tabbing}